<template>
  <div id="box">
    <!-- 搜索输入框 -->
    <div style="" class="search">
      <el-input
        placeholder="请输搜索入内容"
        v-model="query"
        class="input-with-select"
      >
        <!-- 图标 -->
        <el-button slot="append" @click="adm" icon="el-icon-search"></el-button>
      </el-input>
    </div>

    <div class="addTo">
      <el-button type="primary" @click="addTo">添加用户</el-button>
    </div>
  </div>
</template>
<script>
export default {
  props: ["userdata", "dick"],
  data() {
    return {
      list: this.userdata,
      query: "",
    };
  },

  methods: {
    addTo() {
      this.$emit("addTo", true);
    },
    adm() {
      
      this.$emit("querys", this.query);
    },
    edit() {
      //  进行创建数据
      if (this.userdata.id == 2) {
        this.$axios
          .post(
            "https://www.liulongbin.top:8888/api/private/v1/users",
            this.list.list
          )
          .then((rem) => {
            // 数据解构
            let { data, meta } = rem;
            //
            if (meta.status == "201") {
              // 成功的弹框
              this.$message.success(meta.msg);
              this.$emit("userlistt", true);
            } else {
              // 不成功弹框
              this.$message.warning(meta.msg);
            }
          });
      }
    },
    hq() {},
  },
  watch: {
    dick: {
      handler() {
        this.edit();
      },
      deep: true,
    },
  },
};
</script>
<style scoped>
.search {
  display: inline-block;
  width: 30%;
  margin: 0;
}
#box {
  text-align: left;
}
#box div {
  text-align: center;
}
.addTo {
  display: inline-block;
  width: 20%;
}
</style>